<?php
/*
 * Пример
 *        $PhotoModel = new PhotoModel('modul_id',9);
 *        $data = $PhotoModel -> getData();
 */
class UserModel extends BDModel {

    function __construct($column = null, $value = null, $params = null){

        $this->table = "user";
        parent::__construct($column, $value, $params);
        $data = $this->getData();

    }

    function getUser($login, $pass){

        $col_1 = array(
                        'col_name'  => 'user_login',
                        'value'     => $login,
                        'connector' => '',
        );
        $col_2 = array(
                        'col_name'  => 'user_pass',
                        'value'     => $pass,
                        'connector' => 'AND',
        );



        $options = array(
            'columns' => array($col_1, $col_2),
            'table'   => $this->table,
        );

        $query = $this->constructQuery( $options );

        $this->Sql($query);
        $this->Go();

        return $this->getData();
    }

    /*
     * Пилотная версия универсального поиска, который можно вынести в BDModel
     */
    /*
    function getPhotoVmodul($virtual_modul_id, $params = array()){

        $column = 'vmodul_id';

        $offset = '';
        $limit = '';
        $order_by_column = '';
        $order = '';

        if(isset($params['offset'])) $this->offset = $params['offset'];
        if(isset($params['limit'])) $this->limit = $params['limit'];
        if(isset($params['order_by_column'])){
            $this->order_by_column = $params['order_by_column'];
            if( ($s = str_replace(':','',$params['order_by_column'])) != $this->order_by_column){
                $tmp = explode(':',$this->order_by_column);
                $this->order_by_column = $tmp[0] . "." . $tmp[1];
            }
        }
        if(isset($params['order'])) $this->order = $params['order'];

        if($this->offset != ''){
            $this->offset = (int)$this->offset - 1;
            $this->offset = (string)$this->offset;
            $offset = " OFFSET " . $this->offset;
        }
        if($this->limit != '')  $limit  = " LIMIT " . $this->limit;
        if($this->order_by_column != '')  $order_by_column  = " ORDER BY `" . $this->order_by_column . "`";
        if($this->order != '')  $order  =  $this->order;

        if($this->order_by_column != '') $this->order = '';

        #
        if(isset($params['search']))       $this->search = $params['search'];
        if(isset($params['searchField']))  $this->searchField = $params['searchField'];
        if(isset($params['searchOper']))   $this->searchOper = $params['searchOper'];
        if(isset($params['searchString'])) $this->searchString = $params['searchString'];

        $search_condition = '';

        if($this->search == 'true'){
            if($this->searchOper == 'eq') $this->searchOper = ' = ';

            $search_condition = "AND `" . $this->searchField . "` " . $this->searchOper . "'". $this->searchString ."' ";
        }



        $query = "SELECT * FROM `{$this->table}`
                    WHERE `{$column}` = '{$virtual_modul_id}'
                    $search_condition
                     ;";

        $this->Sql($query);
        $this->Go();

        return $this->getData();
    }
    */

}
